import Router from 'koa-router';
import axios from './utils/axios'
import Province from '../dbs/models/province'



let router = new Router({
  // 前缀
  prefix: '/geo'
})

// 定义签名
const sign = '5be6f1e38999ac1af60cbaad320b60cc';

// 获取位置接口

router.get('/getPosition', async (ctx) => {
  let {status,data: {
    province,
    city
  }} = await axios.get(`http://cp-tools.cn/geo/getPosition?sign=${sign}`)
  if (status === 200) {
    ctx.body = {
      province,
      city
    }
  }
  else {
    ctx.body = {
      province: '',
      city: ''
    }
  }
})

export default router
